package com.eascs.workflow.service;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.eascs.admin.o2o.internal.util.StatusContexts;
import com.eascs.admin.o2o.loan.entity.O2oLoanUserEntity;
import com.eascs.admin.o2o.loan.entity.O2oLoanapplyEntity;
import com.eascs.admin.o2o.loan.service.O2oLoanUserService;
import com.eascs.admin.o2o.loan.service.O2oLoanapplyService;
import com.eascs.admin.o2o.loan.utils.BankRate;
import com.eascs.admin.o2o.o2ozx.serviceimpl.O2oZxServiceImpl;
import com.eascs.admin.o2o.zx.entity.O2oZxEntity;
import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.common.util.DateUtils;
import com.eascs.common.util.StringUtil;
import com.eascs.crm.common.entity.CreditRecordDetail;
import com.eascs.crm.common.entity.GuaranteeCreditCardInfo;
import com.eascs.crm.common.entity.GuaranteeInfo;
import com.eascs.crm.common.entity.LoanInfo;
import com.eascs.crm.common.entity.SemiCreditCardInfo;
import com.eascs.crm.common.service.ICustomerInfoService;
import com.eascs.crm.common.vo.Credit;
import com.eascs.crm.common.vo.DebitCardInfo1;
import com.eascs.datalist.entity.O2oDataListEntity;
import com.eascs.datalist.service.O2oDataListService;
import com.eascs.workflow.form.CreditForm;

/**
 * 解析征信报告Service
 * 
 * @author ycz
 *
 */
@Service
public class ZxResolveService {
	private static Logger logger = LoggerFactory.getLogger(ZxResolveService.class);
	@Autowired
	private O2oLoanapplyService o2oloanapplyService;
	@Reference
	private ICustomerInfoService iCustomerInfoService;
	@Autowired
	private O2oDataListService o2oDataListService;
	@Autowired
	private O2oLoanUserService o2oLoanUserService;
	@Autowired
	O2oZxServiceImpl o2oZxServiceImpl;
	
	//增加参数isSpouse，是否配偶
	public CreditForm getZxInfo(O2oLoanapplyEntity loanapplyEntity, String loanId, String code, CreditForm creditForm , String o2oZxEntityId ,boolean isSpouse) {
		O2oDataListEntity userDataEntity = o2oDataListService.findCode(o2oZxEntityId, code);
		O2oLoanapplyEntity o2oLoanapplyEntity=o2oloanapplyService.findById(loanapplyEntity.getLoanapplyNo());
		Credit credit = null;
		if (null != userDataEntity && null != userDataEntity.getUrlpath()) {
			logger.info("开始解析征信报告：customerId[{}],url:[{}]", loanId, userDataEntity.getUrlpath());
			try {
				O2oLoanUserEntity loanUser = o2oLoanUserService.findById(o2oLoanapplyEntity.getLoanId(), o2oLoanapplyEntity.getLoanapplyNo());
				O2oZxEntity o2oZxEntity=new O2oZxEntity();
				if (loanUser!=null) {
					o2oZxEntity=o2oZxServiceImpl.getEntityById(loanUser.getZxNo());
				}
				if (BankRate.BANK_BC.equals(o2oZxEntity.getZxBank()))// 解析中国银行征信报告
					credit = iCustomerInfoService.getCustomerInquiry(loanId, userDataEntity.getUrlpath());
				if (BankRate.BANK_JCB.equals(o2oZxEntity.getZxBank()))// 解析江西银行征信报告
					credit = iCustomerInfoService.getCustomerInquiryJiangxi(loanId, userDataEntity.getUrlpath());
				logger.info("{}征信解析成功,Credit：[{}]", isSpouse?"配偶":"借款人",credit.toString());
			} catch (Exception e) {
				logger.info("编号：[{}],征信解析异常:[{}]", loanapplyEntity.getBillCode(), e.getMessage());
			}
			if (null != credit)
				creditForm = this.getCreditReportEntity(credit, creditForm, code , isSpouse);
			else
				creditForm.setErrorFlag("征信解析失败,重试或者手工编辑征信情况");
		} else {
			logger.info("单号：[{}],中行未返回征信报告", loanapplyEntity.getBillCode());
			creditForm.setErrorFlag("中行未返回征信报告");// 解析失败或者返回对象为空
		}
		return creditForm;
	}

	/**
	 * 构建CreditForm实体
	 * 
	 * @param credit
	 * @param code
	 * @param isSpouse 是否配偶
	 * @return
	 */
	private CreditForm getCreditReportEntity(Credit credit, CreditForm creditForm, String code ,boolean isSpouse) {
		BigDecimal contractTotal = BigDecimal.ZERO;// 贷款合同总额
		BigDecimal bankBalanceOverdue = BigDecimal.ZERO;// 银行机构逾期W1：机构类型显示为银行的当前逾期金额之和
		Integer mortgageHouse = 0;// 住房按揭数 B
		BigDecimal mortgageHouseBalance = BigDecimal.ZERO;// 住房按揭贷款余额 C
		BigDecimal avgmonthRepayHouse = BigDecimal.ZERO;// 住房月均还款额 D
		Integer mortgageCar = 0;// 按揭车辆数 E
		BigDecimal mortgageCarBalance = BigDecimal.ZERO;// 车辆按揭贷款余额F
		BigDecimal avgmonthRepayCar = BigDecimal.ZERO;// 车辆月均还款额G
		BigDecimal creditPaymentBalance = BigDecimal.ZERO;// 信用（含保证）贷款余额H:贷款种类为个人消费贷款、个人经营性贷款、农户贷款、其他；机构类型为：银行；担保方式：信用/免担保、自然人保证、其他、农户联保的本金余额之和
		BigDecimal pledgePaymentBalance = BigDecimal.ZERO;// 抵押贷款余额I:贷款种类为个人消费贷款、个人经营性贷款、农户贷款、其他；机构类型为银行；担保方式为抵押的本金余额之和
		BigDecimal impawnPaymentBalance = BigDecimal.ZERO;// 质押贷款余额J:贷款种类为个人消费贷款、个人经营性贷款、农户贷款、其他；机构类型为银行；担保方式为质押的本金余额之和
		BigDecimal groupAssureBalance = BigDecimal.ZERO;// 组合担保贷款余额K:贷款种类为个人消费贷款、个人经营性贷款、农户贷款、其他；机构类型为：银行；担保方式为组合的本金余额之和
		Integer creditCount = 0;// 持有信用卡张数 M
		BigDecimal creditBalance = BigDecimal.ZERO;// 授信余总额 N
		BigDecimal avgCardusedAmt = BigDecimal.ZERO;// 信用卡最近6个月平均透支额度 O
		BigDecimal creditLimitRate = BigDecimal.ZERO;// 信用卡透支（逾期）P
		BigDecimal creditLimitOverdue = BigDecimal.ZERO;// 信用卡逾期 W3
		BigDecimal nonbankPaymentBalance = BigDecimal.ZERO;// 非银行机构贷款余额L：机构类型为消费金融有限公司、小额贷款公司、信托机构、财务公司的本金余额之和
		BigDecimal nonbankBalanceOverdue = BigDecimal.ZERO;// 非银行机构逾期W2:机构类型为消费金融有限公司、小额贷款公司、信托机构、财务公司的当前逾期金额之和
		Integer outAssureCount = 0;// 担保笔数 Q
		BigDecimal assureTotal = BigDecimal.ZERO;// 担保总额 R
		BigDecimal assureBalance = BigDecimal.ZERO;// 担保余额 S
		Integer creditSearch = 0;// 信用卡、贷款审批查询次数 T
		BigDecimal sixOverBalance = BigDecimal.ZERO;// 夫妻6个月到期金额
		Integer twentyFourOverdueCount = 0;// 近24个月内贷款逾期次数
		Integer twentyFourOverdueTopCount = 0;// 近24个月内贷款逾期金额超过1000元的最高逾期期数
		Integer twentyFourOverdueCreditCount = 0;// 近24个个月信用卡逾期次数
		Integer twentyFourOverdueCreditTopCount = 0;// 24个月内信用卡最高逾期期数
		Date searchTime = null;
		// 征信查询时间
		if (null != credit.getCreditSearchInfo()
				&& StringUtil.isNotBlank(credit.getCreditSearchInfo().getSearch_time())) {
			String date = credit.getCreditSearchInfo().getSearch_time();

			try {
				Date searchDate = null;
				if (date.length() == 10) {
					SimpleDateFormat sdf = DateUtils.FORMATE_CN_DATE;
					searchDate = sdf.parse(date);// 江西银行版本2017.08.07
				} else {// 中行版本
					String date1 = date.substring(7, date.length());
					searchDate = DateUtils.formateStandDateTime(date1);
				}
				searchTime = DateUtils.addMonth(searchDate, 6);
			} catch (ParseException e) {
				logger.error("解析searchDate发生异常，日期字符串：{}", date, e);
			}

		}
		if (null != credit.getCreditSummary()) {
			mortgageHouse = IntegerToZero(credit.getCreditSummary().getSell_house_num() + // 按揭房产：_B_套
					IntegerToZero(credit.getCreditSummary().getBisness_house_num()));
		}
		if (null != credit.getLoanInfoList() && !credit.getLoanInfoList().isEmpty()) {
			for (LoanInfo loanInfo : credit.getLoanInfoList()) {
				if (loanInfo.getLoan_type() != null && loanInfo.getLoan_type().contains(StatusContexts.ZX_HOUSE_TYPE)) {// 住房按揭
					mortgageHouseBalance = BigDecimalToZero(loanInfo.getPrincipal_balance()).add(mortgageHouseBalance);// 住房按揭贷款余额C
					avgmonthRepayHouse = BigDecimalToZero(loanInfo.getRepayment_this_month()).add(avgmonthRepayHouse);// 住房月均还款额D
				} else if (loanInfo.getLoan_type() != null
						&& loanInfo.getLoan_type().contains(StatusContexts.ZX_CAR_TYPE)) {// 车辆按揭
					mortgageCar++;// 按揭车辆数 E
					mortgageCarBalance = BigDecimalToZero(loanInfo.getPrincipal_balance()).add(mortgageCarBalance);// 车辆按揭贷款余额F
					avgmonthRepayCar = BigDecimalToZero(loanInfo.getRepayment_this_month()).add(avgmonthRepayCar);// 车辆月均还款额G
				} else {
					if (loanInfo.getInstitution_type() != null && loanInfo.getInstitution_type().contains(StatusContexts.ZX_BANK_TYPE)) {// 机构类型为：商业银行
						if (loanInfo.getGuarantee_way() != null && loanInfo.getGuarantee_way().contains(StatusContexts.ZX_MORTGAGE_TYPE)) {
							pledgePaymentBalance = BigDecimalToZero(loanInfo.getPrincipal_balance()).add(pledgePaymentBalance);// 抵押贷款余额I
						} else if (loanInfo.getGuarantee_way() != null&& loanInfo.getGuarantee_way().contains(StatusContexts.ZX_PLEDGE_TYPE)) {
							impawnPaymentBalance = BigDecimalToZero(loanInfo.getPrincipal_balance()).add(impawnPaymentBalance);// 质押贷款余额J
						} else if (loanInfo.getGuarantee_way() != null&& loanInfo.getGuarantee_way().contains(StatusContexts.ZX_GROUP_TYPE)) {
							groupAssureBalance = BigDecimalToZero(loanInfo.getPrincipal_balance()).add(groupAssureBalance);// 组合担保贷款余额K
						} else {
							creditPaymentBalance = BigDecimalToZero(loanInfo.getPrincipal_balance()).add(creditPaymentBalance);// 信用（含保证）贷款余额H
						}
					} else {
						nonbankPaymentBalance = BigDecimalToZero(loanInfo.getPrincipal_balance()).add(nonbankPaymentBalance);// 非银行机构贷款余额L
						nonbankBalanceOverdue = BigDecimalToZero(loanInfo.getCurrent_period_amount()).add(nonbankBalanceOverdue);// 非银行机构逾期W2
					}
				}
				if (loanInfo.getInstitution_type() != null&& loanInfo.getInstitution_type().contains(StatusContexts.ZX_BANK_TYPE)) {// 银行机构逾期
					bankBalanceOverdue = BigDecimalToZero(loanInfo.getCurrent_period_amount()).add(bankBalanceOverdue);
				}
				// 夫妻6个月贷款到期金额：查询时间+6个月的时间内的贷款的贷款余额
				if (searchTime != null && loanInfo.getLoan_maturity_date() != null&& loanInfo.getLoan_maturity_date().getTime() <= searchTime.getTime()) {sixOverBalance = BigDecimalToZero(loanInfo.getPrincipal_balance()).add(sixOverBalance);
				}
				// 近24个月内贷款逾期次数
				if (loanInfo.getPayment_record() != null && this.hasDigit(loanInfo.getPayment_record())) {
					int count = this.getNumberCount(loanInfo.getPayment_record());
					twentyFourOverdueCount += count;
					// 近24个月内贷款逾期金额超过1000元的最高逾期期数
					if (loanInfo.getCurrent_period_amount() != null
							&& loanInfo.getCurrent_period_amount().compareTo(new BigDecimal(1000)) == 1) {
						int topCount = this.getNumbers(loanInfo.getPayment_record());
						if (topCount >= twentyFourOverdueCreditTopCount) {
							twentyFourOverdueCreditTopCount = topCount;
						}
					}
				}
			}
		}
		// 未销户贷记卡信息汇总
		if (null != credit.getUnDebitSummary()) {
			creditCount = credit.getUnDebitSummary().getCard_corporate_num() + creditCount;// 持有信用卡张数M
			creditBalance = BigDecimalToZero(credit.getUnDebitSummary().getTotal_credit()).add(creditBalance);// 授信余总额N
			avgCardusedAmt = BigDecimalToZero(credit.getUnDebitSummary().getSix_average_amount()).add(avgCardusedAmt);// 信用卡最近6个月平均透支额度
																														// O
			creditLimitRate = BigDecimalToZero(credit.getUnDebitSummary().getUse_amount()).add(creditLimitRate);// 信用卡透支（逾期）P
		}
		// 未销户准贷记卡信息汇总
		if (null != credit.getUnZdebitSummary()) {
			creditCount = credit.getUnZdebitSummary().getCard_corporate_num() + creditCount;// 持有信用卡张数M
			creditBalance = BigDecimalToZero(credit.getUnZdebitSummary().getTotal_credit()).add(creditBalance);// 授信余总额N
			avgCardusedAmt = BigDecimalToZero(credit.getUnZdebitSummary().getSix_average_amount()).add(avgCardusedAmt);// 信用卡最近6个月平均透支额度O
			creditLimitRate = BigDecimalToZero(credit.getUnZdebitSummary().getUse_amount()).add(creditLimitRate);// 信用卡透支（逾期）P
		}
		// 贷记卡
		if (null != credit.getDebitCardInfo1List() && !credit.getDebitCardInfo1List().isEmpty()) {
			for (DebitCardInfo1 debitCardInfo : credit.getDebitCardInfo1List()) {// 信用卡逾期W3
				creditLimitOverdue = BigDecimalToZero(debitCardInfo.getCurrent_period_amount()).add(creditLimitOverdue);
				// 近24个个月信用卡逾期次数
				if (debitCardInfo.getPayment_record() != null && this.hasDigit(debitCardInfo.getPayment_record())) {
					int count = this.getNumberCount(debitCardInfo.getPayment_record());
					twentyFourOverdueCreditCount += count;
					// 24个月内信用卡最高逾期期数
					int topCount = this.getNumbers(debitCardInfo.getPayment_record());
					if (topCount >= twentyFourOverdueTopCount) {
						twentyFourOverdueCreditTopCount = topCount;
					}
				}
			}
		}
		// 准贷记卡
		if (null != credit.getSemiCreditCardInfoList() && !credit.getSemiCreditCardInfoList().isEmpty()) {
			for (SemiCreditCardInfo semiCreditCardInfo : credit.getSemiCreditCardInfoList()) {// 信用卡逾期W3
				creditLimitOverdue = BigDecimalToZero(semiCreditCardInfo.getOutstanding_balance())
						.add(creditLimitOverdue);
			}
		}
		// 对外贷款担保信息
		if (null != credit.getGuaranteeInfoList()) {
			if(!credit.getGuaranteeInfoList().isEmpty()){
				outAssureCount = credit.getGuaranteeInfoList().size();// 担保笔数 Q
				for (GuaranteeInfo guaranteeInfo : credit.getGuaranteeInfoList()) {
					assureTotal = BigDecimalToZero(guaranteeInfo.getGuaranteed_amount()).add(assureTotal);// 担保总额R
					assureBalance = BigDecimalToZero(guaranteeInfo.getPrincipal_balance()).add(assureBalance);// 担保余额S
				}
			}
		}
		
		// 对外信用卡担保信息
		if (null != credit.getGuaranteecreditCardInfoList()) {
			if(!credit.getGuaranteecreditCardInfoList().isEmpty()){
				outAssureCount += credit.getGuaranteecreditCardInfoList().size(); 
				for (GuaranteeCreditCardInfo guaranteeCreditCardInfo : credit.getGuaranteecreditCardInfoList()) {
					assureTotal = BigDecimalToZero(guaranteeCreditCardInfo.getGuaranteedAmount()).add(assureTotal);// (信用卡担保金额)担保总额R
					assureBalance = BigDecimalToZero(guaranteeCreditCardInfo.getPrincipalBalance()).add(assureBalance);// (信用卡已用额度)担保余额S
				}
			}
		}
		// 信用卡、贷款审批查询次数T 日期可以直接用当前日期处理即可
		if (null != credit.getCreditRecordDetailList() && !credit.getCreditRecordDetailList().isEmpty()) {// 信用卡、贷款审批查询次数T
			Date dateMonth = DateUtils.addMonth(new Date(), -2);
			for (CreditRecordDetail creditRecordDetail : credit.getCreditRecordDetailList()) {
				if (dateMonth.getTime() <= creditRecordDetail.getQuery_date().getTime()
						&& creditRecordDetail.getQuery_date().getTime() <= new Date().getTime()) {
					creditSearch++;
				}
			}
		}
		// 征信总额 A
		contractTotal = creditBalance;
		// 未结清贷款信息汇总
		if (null != credit.getUnLoaninfoSummary()) {// 未结清贷款信息汇总 A
			contractTotal = BigDecimalToZero(credit.getUnLoaninfoSummary().getTotal_amount()).add(creditBalance);
		}
		if (!isSpouse) {
			creditForm.setMortgageHouse(mortgageHouse);
			creditForm.setContractTotal(contractTotal.doubleValue());
			creditForm.setBankBalanceOverdue(bankBalanceOverdue.doubleValue());
			creditForm.setMortgageHouseBalance(mortgageHouseBalance.doubleValue());
			creditForm.setAvgmonthRepayHouse(avgmonthRepayHouse.doubleValue());
			creditForm.setMortgageCar(mortgageCar);
			creditForm.setMortgageCarBalance(mortgageCarBalance.doubleValue());
			creditForm.setAvgmonthRepayCar(avgmonthRepayCar.doubleValue());
			creditForm.setCreditPaymentBalance(creditPaymentBalance.doubleValue());
			creditForm.setPledgePaymentBalance(pledgePaymentBalance.doubleValue());
			creditForm.setImpawnPaymentBalance(impawnPaymentBalance.doubleValue());
			creditForm.setGroupAssureBalance(groupAssureBalance.doubleValue());
			creditForm.setCreditCount(creditCount);
			creditForm.setCreditBalance(creditBalance.doubleValue());
			creditForm.setAvgCardusedAmt(avgCardusedAmt.doubleValue());
			creditForm.setCreditLimitRate(creditLimitRate.doubleValue());
			creditForm.setCreditLimitOverdue(creditLimitOverdue.doubleValue());
			creditForm.setNonbankPaymentBalance(nonbankPaymentBalance.doubleValue());
			creditForm.setNonbankBalanceOverdue(nonbankBalanceOverdue.doubleValue());
			creditForm.setOutAssureCount(outAssureCount);
			creditForm.setAssureTotal(assureTotal.doubleValue());
			creditForm.setAssureBalance(assureBalance.doubleValue());
			creditForm.setCreditSearch(creditSearch);
			creditForm.setSixOverBalance(sixOverBalance.doubleValue());
			creditForm.setTwentyFourOverdueCount(twentyFourOverdueCount);
			creditForm.setTwentyFourOverdueTopCount(twentyFourOverdueTopCount);
			creditForm.setTwentyFourOverdueCreditCount(twentyFourOverdueCreditCount);
			creditForm.setTwentyFourOverdueCreditTopCount(twentyFourOverdueCreditTopCount);
		} else {
			creditForm.setMortgageHouse1(mortgageHouse);
			creditForm.setContractTotal1(contractTotal.doubleValue());
			creditForm.setBankBalanceOverdue1(bankBalanceOverdue.doubleValue());
			creditForm.setMortgageHouseBalance1(mortgageHouseBalance.doubleValue());
			creditForm.setAvgmonthRepayHouse1(avgmonthRepayHouse.doubleValue());
			creditForm.setMortgageCar1(mortgageCar);
			creditForm.setMortgageCarBalance1(mortgageCarBalance.doubleValue());
			creditForm.setAvgmonthRepayCar1(avgmonthRepayCar.doubleValue());
			creditForm.setCreditPaymentBalance1(creditPaymentBalance.doubleValue());
			creditForm.setPledgePaymentBalance1(pledgePaymentBalance.doubleValue());
			creditForm.setImpawnPaymentBalance1(impawnPaymentBalance.doubleValue());
			creditForm.setGroupAssureBalance1(groupAssureBalance.doubleValue());
			creditForm.setCreditCount1(creditCount);
			creditForm.setCreditBalance1(creditBalance.doubleValue());
			creditForm.setAvgCardusedAmt1(avgCardusedAmt.doubleValue());
			creditForm.setCreditLimitRate1(creditLimitRate.doubleValue());
			creditForm.setCreditLimitOverdue1(creditLimitOverdue.doubleValue());
			creditForm.setNonbankPaymentBalance1(nonbankPaymentBalance.doubleValue());
			creditForm.setNonbankBalanceOverdue1(nonbankBalanceOverdue.doubleValue());
			creditForm.setOutAssureCount1(outAssureCount);
			creditForm.setAssureTotal1(assureTotal.doubleValue());
			creditForm.setAssureBalance1(assureBalance.doubleValue());
			creditForm.setCreditSearch1(creditSearch);
			creditForm.setSixOverBalance1(sixOverBalance.doubleValue());
			creditForm.setTwentyFourOverdueCount1(twentyFourOverdueCount);
			creditForm.setTwentyFourOverdueTopCount1(twentyFourOverdueTopCount);
			creditForm.setTwentyFourOverdueCreditCount1(twentyFourOverdueCreditCount);
			creditForm.setTwentyFourOverdueCreditTopCount1(twentyFourOverdueCreditTopCount);
		}
		return creditForm;
	}

	/**
	 * Integer 为空值转成0
	 * 
	 * @param decimal
	 * @return
	 */
	public Integer IntegerToZero(Integer decimal) {
		if (decimal == null) {
			decimal = 0;
		}
		return decimal;
	}

	/**
	 * BigDecimal空值处理转换单位为万元
	 * 
	 * @return
	 */
	public BigDecimal BigDecimalToZero(BigDecimal decimal) {
		if (decimal == null) {
			decimal = BigDecimal.ZERO;
		} else {
			BigDecimal count = new BigDecimal(10000);
			decimal = decimal.divide(count, 4, RoundingMode.HALF_UP);
		}
		return decimal;
	}
	// 判断是否包含数字
	// 判断一个字符串是否含有数字

	public boolean hasDigit(String content) {
		boolean flag = false;
		Pattern p = Pattern.compile(".*\\d+.*");
		Matcher m = p.matcher(content);
		if (m.matches())
			flag = true;
		return flag;
	}

	// 截取数字 求最大值
	public Integer getNumbers(String content) {
		String[] str = content.split(" ");
		int a = 0;
		for (int i = 0; i < str.length; i++) {
			if (this.hasDigit(str[i])) {
				int b = Integer.valueOf(str[i].toString());
				if (b >= a) {
					a = b;
				}
			}
		}
		return a;
	}

	// 截取数字 累计
	public Integer getNumberCount(String content) {
		String[] str = content.split(" ");
		int a = 0;
		for (int i = 0; i < str.length; i++) {
			if (hasDigit(str[i])) {
				++a;
			}
		}
		return a;
	}

	public static void main(String[] args) {
		// String conternt="/ / 1 1 / / 1 / / / / / / / / / N N N N N N 1 2";
		// System.out.println(getNumberCount(conternt));
		BigDecimal assureTotal = new BigDecimal(5);
		BigDecimal b2 = assureTotal.divide(new BigDecimal(2), 4, RoundingMode.HALF_UP);
		System.out.println(b2.doubleValue());
	}
}
